package coasttocoast.game;

/**
 * @author gsh
 */
public abstract class Unit extends Entity {
  private Player owner;
  private Cell location;
  private int health;

  public Unit(int id) {
    super(id);
    health = getMaxHealth();
  }

  public int getHealth() {
    return health;
  }

  public Player getOwner() {
    return owner;
  }

  public void destroy() {
    location.getUnits().remove(this);
    // TODO(gsh): Create a EntityListener/UnitListener interface and fire an event on that.
    // Could remove this unit from the Cell and/or board via listeners or using a direct access here.
    // Probably best handled via listeners for the events.
  }

  public void modifyHealth(int value) {
    health = Math.min(getMaxHealth(), health + value);
    if (health < 0) {
      destroy();
    }
  }

  public abstract int getMovement();

  public abstract int getAttack();

  public abstract int getMaxHealth();
}
